<template>
  <view class="container">
    <view class="title">请选择组队方式</view>
    <view class="btn-group">
      <u-button @click="selectSingle" type="primary">单人组队</u-button>
      <u-button @click="selectTeam" type="primary">团队组队</u-button>
    </view>
  </view>
</template>

<script>
export default {
  data(){
    return{
      competitionName: '',
      groupNumber:'',
    }
  },
  
  onLoad(option){
    this.competitionName = option.name;
    this.groupNumber = option.groupNumber
  },
  methods: {
    selectSingle() {
      // 跳转到单人组队页面
      console.log(this.groupNumber);
      if(this.groupNumber == 1){
         uni.navigateTo({
          url: `/pages/enter/enter?name=${this.competitionName}&groupNumber=${this.groupNumber}`
        });
      }else{
        uni.showToast({
          title: '该比赛需要团队报名',
          icon: 'none'
        })
      } 
    },
    selectTeam() {
      // 跳转到团队组队页面
       console.log(this.groupNumber);
       if(this.groupNumber == 1){
         uni.showToast({
           title: '该比赛需要单人报名',
           icon: 'none'
         })
       }else{
          uni.navigateTo({
          url: `/pages/enter/TeamEnter?name=${this.competitionName}&groupNumber=${this.groupNumber}`
        });
       }
     
    }
  }
}
</script>

<style>
.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
}

.title {
  font-size: 24px;
  margin-bottom: 20px;
}

.btn-group {
  display: flex;
  justify-content: space-between;
  width: 60%;
}
</style>
